<template>
  <div class="healthInfo pd-20">

    <el-button @click="handle(1,0)"
               type="primary">消息发送</el-button>

    <el-table :data="tableData"
              style="width: 100%"
              border
              class="mt-20">
      <el-table-column align="center"
                       type="index"
                       min-width="20"></el-table-column>
      <el-table-column align="center"
                       prop="title"
                       label="发送类型">
        <template slot-scope="scope">
          <span>{{scope.row.type == 1 ?'个推':'群发'}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center"
                       label="发送时间"
                       width="150">
        <template slot-scope="scope">
          <span>{{commonFunction.timestampFormat(new Date(scope.row.createTime), 'yyyy-MM-dd hh:mm:ss')}}</span>
        </template>
      </el-table-column>
      <el-table-column align="center"
                       prop="sourceName"
                       label="消息内容">
        <template slot-scope="scope">
          <span>{{scope.row.message}}</span>
        </template>
      </el-table-column>

      <el-table-column align="center"
                       width="150"
                       label="操作">
        <template slot-scope="scope">
          <el-button type="info"
                     @click="handle(3,scope.row)">详 情</el-button>
        </template>
      </el-table-column>
    </el-table>
    <page @getList="_getList"
          :pageTotal="pageTotal"
          ref="page"></page>
    <adddialog v-if="showdialog"
               :dialogData='dialogData'
               @closedialog='showdialog=false;_getList()' />
  </div>
</template>

<script>
  import Page from '@/base/page/page'
  import adddialog from './dialog'
  import { mapGetters } from 'vuex'

  export default {
    name: "healthInfo",
    data () {
      return {
        options1: [],
        param: {},
        tableData: [],
        pageTotal: 0,
        typeItems: [{
          value: 1,
          name: '三级甲等'
        }, {
          value: 0,
          name: '三级乙等'
        }],
        showdialog: false,
        dialogData: {
          show: true,
          info: {}
        }
      }
    },
    mounted () {
      this._getList()
    },
    methods: {
      closeDialog () {

      },
      handle (index, row) {
        switch (index) {
          case 3:
            this.showdialog = true
            this.dialogData = {
              show: true,
              info: row,
              title: '查看',
              canup: false
            }
            break
          case 2:
            break;
          case 1:
            this.showdialog = true
            this.dialogData = {
              show: true,
              info: null,
              title: '新增系统消息',
              canup: true
            }
            break
        }
      },


      _getList () {
        this.param.pageIndex = this.page.pageIndex
        this.param.pageSize = this.page.pageSize

        this.post(this.api.cooperationHospital.getMessageRecordList, this.param).then(res => {
          if (res.data.code === '200') {
            this.tableData = res.data.object
            this.pageTotal = res.data.totalNum
          } else {
            this.$message.warning(res.data.message)
          }
        })
      },
    },
    computed: {
      ...mapGetters([
        'page'
      ])
    },
    components: {
      Page,
      adddialog
    }
  }
</script>

<style scoped lang="scss" type="text/scss" rel="stylesheet/scss">
  .information {
    margin: 10px 0px 0px 0px;
  }

  .btn_1 {
    margin-left: 10px;
  }

  .el-select {
    width: 90%;
  }

  .editorForm {
    height: 750px;
  }

  .editor {
    position: fixed;
    margin-left: -70px;
    width: 70%;
    height: 700px;
    float: left;
  }

  .info {
    height: 750px;
    width: 30%;
    position: absolute;
    top: 78px;
  }

  .info .el-input {
    width: 90%;
  }

  .avatar-uploader {
    width: 100px;
    height: 100px;
    border: 1px dashed #606266;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
  }

  .avatar-uploader:hover {
    border-color: #409eff;
  }

  .avatar-uploader .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 98px;
    height: 98px;
    line-height: 100px;
    text-align: center;
  }

  .avatar {
    width: 100px;
    height: 100px;
    display: block;
  }

  .formTitle {
    display: inline-block;
    line-height: 24px;
    font-size: 18px;
    color: #303133;
  }

  .return {
    float: right;
  }
</style>
<style>
  .ivu-select-input {
    border-radius: 4px !important;
  }
</style>
